#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>

#include "common/simpletlv.h"

int main(int vv, char** cc){
	char * packed=0 ;
	int packlen=0;

	char* test="hello";
	char* test2="kung fuck\n";
	char* test3="big titty\0nn";
	tlv_pack(&packed, &packlen, 45, strlen(test), test); 
	tlv_pack(&packed, &packlen, 40, strlen(test2), test2); 
	tlv_pack(&packed, &packlen, 100, 0, 0); 
	tlv_pack(&packed, &packlen, 42, 12, test3); 

	printf("packed length=%d\n", packlen);

	tlv_showpacked(packed, packlen, stdout);	

	char* value;
	int len;
	int tag;

	value=0;
	tlv_unpack(&packed, &packlen, &tag, &len, &value);
	tlv_show(value, len, stdout);
	free(value);

	value=0;
	tlv_unpack(&packed, &packlen, &tag, &len, &value);
	tlv_show(value, len, stdout);
	free(value);

	value=0;
	tlv_unpack(&packed, &packlen, &tag, &len, &value);
	tlv_show(value, len, stdout);
	free(value);

	value=0;
	tlv_unpack(&packed, &packlen, &tag, &len, &value);
	tlv_show(value, len, stdout);
	free(value);
}
